<%@ page language="java" pageEncoding="utf-8"  isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加用户</title>
<script type="text/javascript">
    function method01(){
        var spannameElement = document.getElementById('usernameerror');
        spannameElement.innerHTML='<font color="red">* 用户名在4~11位</font>';
        var spanpasswordElement = document.getElementById('userpassworderror');
        spanpasswordElement.innerHTML='<font color="red">* 密码在6~14位</font>'

        var usernameElement = document.getElementsByName('user_name');
        var uesrnamecontent = usernameElement[0].value;
        if(!(uesrnamecontent!=null&&uesrnamecontent.length>=4&&uesrnamecontent.length<=11)){
            spannameElement.innerHTML='<font color="red">用户名错误！</font>'
            return;//方法结束
        }

        var userpasswordElement = document.getElementsByName('user_password');
        var userpasswordcontent = userpasswordElement[0].value;
        if(!(userpasswordcontent!=null&&userpasswordcontent.length>=6&&userpasswordcontent.length<=14)){
            spanpasswordElement.innerHTML='<font color="red">密码错误！</font>'
            return;
        }

        var formElement = document.getElementById('myform');
        formElement.action='${pageContext.request.contextPath }/servlet/adduserservlet';
        formElement.method='post';
        formElement.submit();
    }
</script>
</head>
<body>
<form id="myform">
  用户名：<input type="text" name="user_name"><span id="usernameerror"><font color="red">* 用户名在4~11位</font></span><br>
  密&nbsp;&nbsp;&nbsp; 码：<input type="password" name="user_password"><span id="userpassworderror"><font color="red">* 密码在6~14位</font></span><br>
 身份证号：<input type="text" name="user_idcard"><br>
 部&nbsp;&nbsp;&nbsp;门：<select name="select_dept">
      <option >==请选择==</option>
      <c:forEach var="dept" items="${deptInfo}">
          <option value=${dept.deptName}>${dept.deptName}</option>
      </c:forEach>
  </select><br>
  描&nbsp;&nbsp;&nbsp; 述：<input type="text" name="user_desc"><br>
  状&nbsp;&nbsp;&nbsp;态：<input type="radio" name="user_status" value="1" checked="checked"> 启用
     <input type="radio" name="user_status" value="0"> 禁用<br>
<input type="button" value="提交" onclick="method01()">
<input type="reset" value="重置">
</form>
</body>
</html>